<?php
require_once('appcomponent.php');
class Widget extends AppComponent
{
    protected $controller;
    protected $CI;
    
    public function setCI($value){ $this->controller = $value;}
    public function getCI(){ return $this->CI;}
    
    public function init($params = null){
        if (is_array($params))
            foreach($params as $prop => $value)
                $this->$prop = $value;                        
        $this->CI = & get_instance();
    }
    
    public function render($data = null){
        $view = APPPATH . 'widgets/' . get_class($this) . 'View.php';
        if (is_array($data))
            foreach($data as $key => $value)
                $$key = $value;
            
        include($view);
    }
    
    public function run(){
        return $this->render();
    }
}
?>
